package com.api.shopapi.service.impl;

import com.api.shopapi.entity.ElderlyDrugRecord;
import com.api.shopapi.entity.UserFace;
import com.api.shopapi.mapper.UserFaceMapper;
import com.api.shopapi.service.UserFaceService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("UserFaceServiceImplOne")
public class UserFaceServiceImplOne implements UserFaceService {

    @Autowired
    private UserFaceMapper userFaceMapper;

    @Override
    public
    int insert(UserFace userFace){
        return userFaceMapper.insert(userFace);
    }

    @Override
    public
    int delete(String userFaceCode){
        return userFaceMapper.delete(userFaceCode);
    }

    @Override
    public
    int update(UserFace userFace){
        return userFaceMapper.update(userFace);
    }

    @Override
    public UserFace getByUserFaceCode(String userFaceCode){
        return userFaceMapper.getByUserFaceCode(userFaceCode);
    }

    @Override
    public
    UserFace getByUserCode(String userCode){
        return userFaceMapper.getByUserCode(userCode);
    }


    @Override
    public
    PageInfo<UserFace> pageByInsCode(int pageIndex, int pageSize, String institutionCode,String userName,int userType){
        PageHelper.startPage(pageIndex, pageSize);
        List<UserFace> elderlyDrugRecordList = userFaceMapper.listByInsCode(institutionCode,userName,userType);
        PageInfo<UserFace> pageInfo = new PageInfo<>(elderlyDrugRecordList);
        return pageInfo;
    }

    @Override
    public
    PageInfo<UserFace> pageByGovCode(int pageIndex,int pageSize,String governmentCode,
                                     String userName,int userType){
        PageHelper.startPage(pageIndex, pageSize);
        List<UserFace> elderlyDrugRecordList = userFaceMapper.listByGovCode(governmentCode,userName,userType);
        PageInfo<UserFace> pageInfo = new PageInfo<>(elderlyDrugRecordList);
        return pageInfo;
    }


}
